import cv2
import mediapipe as mp
import time

cap = cv2.VideoCapture("C:\\Users\\86191\\Videos\\cl.mp4")
frame_width = int(cap.get(3))
frame_height = int(cap.get(4))
fourcc = cv2.VideoWriter_fourcc(*'XVID')
vm = cv2.VideoWriter('cl.avi', fourcc, 20.0, (frame_width, frame_height))

Ptime = 0
mpPose = mp.solutions.pose
pose = mpPose.Pose()
mpDraw = mp.solutions.drawing_utils

while True:
    ret,frame = cap.read()
    frameRGB = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
    results = pose.process(frameRGB)
    if results.pose_landmarks:
        mpDraw.draw_landmarks(frame,results.pose_landmarks,mpPose.POSE_CONNECTIONS)
        for id,lm in enumerate(results.pose_landmarks.landmark):
            h, w, c = frame.shape
            cx,cy = int(lm.x*w), int(lm.y*h)
            cv2.circle(frame,(cx,cy),5,(255,0,0),cv2.FILLED)

    Ctime = time.time()
    fps = 1/(Ctime-Ptime)
    Ptime = Ctime
    cv2.putText(frame,'FPS:'+str(int(fps)),(10,70),cv2.FONT_HERSHEY_PLAIN,3,(0,255,0),3)
    vm.write(frame)
    cv2.imshow('frame',frame)
    cv2.waitKey(1)